libs/gnttab: fix FreeBSD gntdev interface
authorRoger Pau Monne <roger.pau@citrix.com>
Tue, 17 Apr 2018 13:03:41 +0000 (14:03 +0100)
committerWei Liu <wei.liu2@citrix.com>
Thu, 19 Apr 2018 14:50:16 +0000 (15:50 +0100)
commitaf7e907c33e7a8d81448e3fd2ce7939e24b200f8
tree5966fe3b6250bfb0f366218539d9b3e1d3963587
parentef3ab46493f650b7e5cca2b2578a99ca0cbff195
libs/gnttab: fix FreeBSD gntdev interface

Current interface to the gntdev in FreeBSD is wrong, and mostly worked
out of luck before the PTI FreeBSD fixes, when kernel and user-space
where sharing the same page tables.

On FreeBSD ioctls have the size of the passed struct encoded in the ioctl
number, because the generic ioctl handler in the OS takes care of
copying the data from user-space to kernel space, and then calls the
device specific ioctl handler. Thus using ioctl structs with variable
sizes is not possible.

The fix is to turn the array of structs at the end of
ioctl_gntdev_alloc_gref and ioctl_gntdev_map_grant_ref into pointers,
that can be properly accessed from the kernel gntdev driver using the
copyin/copyout functions. Note that this is exactly how it's done for
the privcmd driver.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/include/xen-sys/FreeBSD/gntdev.h
tools/libs/gnttab/freebsd.c